package com.wl.designpattern.iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wangliang on 2021/2/23.
 */
public class DeliveryAggregate implements Aggregate {
    private List<String> list = new ArrayList<>();//内部使用list来存储数据

    @Override
    public int size() {
        return list.size();
    }

    @Override
    public String get(int position) {
        return list.get(position);
    }

    @Override
    public void add(String tel) {
        list.add(tel);
    }

    @Override
    public void remove(String tel) {
        list.remove(tel);
    }

    @Override
    public Iterator iterator() {
        return new DeliveryIterator(this);
    }
}
